package tcp.chat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;

public class xx extends Thread {
    private InetAddress ip;
    private int post;
    private String name;

    private BufferedReader buff = null;//从字符输入流读取文本，缓冲字符，以提供字符，数组和行的高效读取。

    public xx(String name, InetAddress ip, int post) {
        this.name = name;
        this.ip = ip;
        this.post = post;
    }

    @Override
    public void run() {
        buff = new BufferedReader(new InputStreamReader(System.in));//取出命令行中的内容
        try {
            while (true) {
                String ml = buff.readLine();
                String xx = name + ":" + ml;
                new tcp_send(ip, post, xx).start();
                if (ml.matches(".*bey.*")) {
                    System.out.println("发送模块关闭");
                    break;
                }
            }
            buff.close();

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (buff != null) {
                try {
                    buff.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
